<html>
<head lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" >
    <title>新增日志</title>
    [#include "../../common.ftl"]
    [@includeCommonJS /]
</head>
<body>

<div id="mainScroll">

    <div class="content">
    <div class="panel">
    <div class="panel-heading">日志信息</div>
        <div class="panel-body">
            <form class="form-horizontal" name="bizLogEditForm" id="bizLogEditForm" action="/logger/bizLog/saveOrUpdate" method="post">
                <input type="hidden" id="bizLogId" name="bizLogId" value="${(bizLog.id)}">
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>企业：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" name="companyId" id="companyId" value="${bizLog.companyId}" placeholder="" maxlength="20">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>应用：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" name="applicationId" value="${bizLog.applicationId}" placeholder="" maxlength="10">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>模块：</label>
                    <div class="col-sm-4">
                        <input class="form-control" type="text" name="moduleId" value="${bizLog.moduleId}" placeholder="" maxlength="10">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>日志类型：</label>
                    <div class="col-sm-4">
                        <select id="operatorType" name="operatorType" style="width:100%;">
                            <option value="0" [#if bizLog.peratorType = "0"]selected[/#if]>用户</option>
                            <option value="1" [#if bizLog.operatorType = "1"]selected[/#if]>系统</option>
                            <option value="2" [#if bizLog.operatorType = "2"]selected[/#if]>任务</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>是否可见：</label>
                    <div class="col-sm-4 row">
                        <label class="radio-inline">
                            <input type="radio" name="visible" value="1" > 是
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="visible" value="0" checked> 否
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="text-danger">*&nbsp;</span>内容：</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" rows="5" id="content" name="content" onkeyup="checkInputLimit('content','msg','100');" onblur="checkInputLimit('content','msg','100');">${(bizLog.content)!}</textarea>
                        <span id="msg"> 已输入:[#if (bizLog.content)??]${(bizLog.content)?length} [#else]0[/#if]/500字符</span>
                    </div>
                </div>
                <div class="blank-20"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-8">
                        <button type="button" class="btn btn-default btn-l"  onclick="backToMain('${request.contextPath}/bizLog/search');">返回</button>&nbsp;&nbsp;
                        <button class="btn btn-success btn-l" type="submit">确认保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>

</body>
</html>
<script type="text/javascript">

    $(function(){
        // icheck
        $("input").iCheck({
            checkboxClass: "icheckbox_minimal-blue",
            radioClass: "iradio_minimal-blue",
            increaseArea: "20%" // optional
        });

        //黑色工具提示
        $('button[data-toggle="tooltip"]').tooltip();

        //带搜索下拉
        $("select").select2({
            minimumResultsForSearch: Infinity
        });

        //左侧导航滚动条
        $("#mainScroll").mCustomScrollbar({
            theme:"dark-thin"
        });

        // 控制页面控件的选中状态
        [#if bizLog.visible]
            $("input[name='visible'][value='1']").iCheck('check');
        [#else]
            $("input[name='visible'][value='0']").iCheck('check');
        [/#if]


    });


    $(function() {
        $('#bizLogEditForm').bootstrapValidator({
            fields: {
                code: {
                    validators: {
                        notEmpty: {
                            message: '编号不能为空'
                        },
                        regexp: {
                            regexp: /^[a-zA-Z0-9_]+$/,
                            message: '编号只能包含字母数字和下划线'
                        }
                    }
                },
                companyId: {
                    validators: {
                        notEmpty: {
                            message: '企业不能为空'
                        }
                    }
                },
                applicationId: {
                    validators: {
                        notEmpty: {
                            message: '应用不能为空'
                        }
                    }
                },
                moduleId: {
                    validators: {
                        notEmpty: {
                            message: '模块不能为空'
                        }
                    }
                },
                content: {
                    validators : {
                        notEmpty: {
                            message: '内容不能为空'
                        }
                    }
                }
            },
            submitHandler: function(validator, form, submitButton) {
                var code = $("#code").val();
                var codeOld = $("#codeOld").val();
                if(code != codeOld) {
                    $.post("/logger/bizLog/checkDuplicate", {"code":code}, function(result) {
                        if(result == "ERROR") {
                            BootstrapDialog.alert({title: "信息", message: "编号重复!",buttonLabel : "确定"});
                            $('#bizLogEditForm').bootstrapValidator('disableSubmitButtons', false);
                            return false;
                        } else {
                            validator.defaultSubmit();
                        }
                    }, "text");
                } else {
                    validator.defaultSubmit();
                }
            }
        })
    });

</script>